//
//  shopDetailView.m
//  ZiJinLian
//
//  Created by 🐛 on 2017/5/2.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "shopDetailView.h"
#import "UIView+Extension.h"
@implementation shopDetailView
- (id)initWithFrame:(CGRect)frame creatView:(NSArray *)tagArray NSArray:(NSArray *)serviceArray titleString:(NSString *)titleString
{
    if (self = [super initWithFrame:frame])
    {
        int count = 0;
        float btnWidth = 0;
        float viewHeight = 0;
        for (int i = 0; i < self.tagArray.count; i++) {
            
            NSString *btnName = @"新品首发";
            
            UILabel *label = [[UILabel alloc]init];
            [label setBackgroundColor:Red_Color];
            [label setTextColor:[UIColor whiteColor]];
            label.textAlignment=1;
            label.text=btnName;
            label.font = FontAndStyle12;
            ViewRadius(label, 3);
            //NSDictionary *dict = [NSDictionary dictionaryWithObject:FONT(12) forKey:NSFontAttributeName];
            CGSize btnSize = [label.text sizeWithAttributes:@{NSFontAttributeName:label.font }];
            
            label.width = btnSize.width + 15;
            label.height = btnSize.height + 12;
            
            if (i==0)
            {
                label.x = 10;
                btnWidth = CGRectGetMaxX(label.frame);
            }
            else{
                btnWidth += CGRectGetMaxX(label.frame)+10;
                if (btnWidth > MainW) {
                    count++;
                    label.x = 10;
                    btnWidth = CGRectGetMaxX(label.frame);
                }else{
                    label.x += btnWidth - label.bsg_width;
                }
            }
            label.y += count * (label.bsg_height+10)+10;
            
            viewHeight = CGRectGetMaxY(label.frame)+10;
            
            [self addSubview:label];
            
            label.tag = 10000+i;
            
        }
        self.bsg_height = viewHeight;
        
        self.height = self.bsg_height;
        self.shopName=[[UILabel alloc]initWithFrame:CGRectMake(10, viewHeight, MainW, 15)];
        self.shopName.font=FontAndStyle14;
        self.shopName.textColor=TextColor3;
        [self addSubview:self.shopName];
    }
    return self;
}

-(void)creatView:(NSArray *)tagArray NSArray:(NSArray *)serviceArray titleString:(NSString *)titleString{
    
    
}

@end
